﻿@using DataModel
@model ViewModels.GuestBookVM.GuestBookMainVM
@{
    ViewBag.Title = "Hinoky.com :::: 방명록";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<style type="text/css">
    .masterIcon {
        width: 21px;
        height: 21px;
    }
</style>


<script src="~/Scripts/customJS/guestbookLib.js"></script>
<script type="text/javascript">
    guestbookLib({ locationCode: '@ViewBag.Location', subKey: '@ViewBag.SubKey' });
</script>

<div class="bs-callout bs-callout-article">
    <h3>방명록</h3>
    <p>운영자에게 아는척을 해주세요.</p>
</div>
    
<div class="well">
    <div class="text-right">
        <a id="btnAdd" class="btn btn-success">글 남기기</a>
    </div>

    <hr />
    <div id="divGuestBookList">
        @foreach (var guestBook in Model.GuestBookList)
        {
            <div id="divRow_@guestBook.Idx" class="row">
                <div class="col-md-12">
                    @if (WebLib.AuthorizeService.MemberInfo.Instance.UserRole.Contains("ADMIN") && guestBook.IsPrivate)
                    {
                        <span class="glyphicon glyphicon-send secret-guestbook"></span>                                   
                    }
                    else
                    {
                        <span class="glyphicon glyphicon-send general-guestbook"></span>
                    }
                    <b>@Html.Raw(guestBook.GuestName)</b>
                    <span class="pull-right">@guestBook.InsertDate.ToString("yyyy-MM-dd")</span>
                    <p>@guestBook.Comment <span onclick="saveReply('@guestBook.Idx'); return false;" data-ParentIdx="@guestBook.Idx" class="glyphicon glyphicon-comment btn-reply">댓글쓰기</span></p>
                    <hr />
                
                    <div id="divDetailList_@guestBook.Idx">
                        <!-- (s) 방명록의 댓글 (s) -->
                        @foreach (var replyItem in guestBook.ReplyList)
                        {
                            <div class="col-md-12">
                                <span class="glyphicon glyphicon-chevron-right replyName">
                                    @Html.Raw(replyItem.GuestName)
                                </span>
                                <span>@replyItem.Comment</span>
                                <em>(@replyItem.InsertDate.ToString("yyyy-MM-dd"))</em>
                                @if (WebLib.AuthorizeService.MemberInfo.Instance.UserRole.Contains("ADMIN"))
                                {
                                    <span class="h6">@("(" + replyItem.IPAddress +")")</span>
                                }
                            </div>
                            <hr />
                        }
                    </div>
                </div>
            </div>
        <hr>
        }
        
        <input type="hidden" id="hidLastGuestBookIdx" name="hidLastGuestBookIdx" value="@Model.GuestBookLastIdx" />
    </div>
</div>

